home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2003 November / PCWK1103B.iso / DesignCAD 3D Max PLUS trial 30 / DATA1.CAB / Example_Files / Sample_Macros / 600_6_Master.d3m < prev    next >
Encoding:
Text File  |  2003-09-29  |  13.3 KB  |  687 lines

  1. ' This is the sixth macro in the 600 series, which draws the small
  2. ' area summary boxes and the large material summary boxes.
  3. '
  4. ' Clear all Variables
  5.     Clear
  6. ' Get values from the ASCII text data file.
  7. '
  8. ' Based on RType chosen by user above
  9.         open "i", 1, "*\sample macros\600.txt"
  10. ' Assign #s found to Variables
  11.     Input #1, AddLen
  12.     Input #1, TH
  13.     Input #1, PanNum2
  14.     Input #1, PanNum
  15. ' Close File
  16.     Close #1
  17. '
  18. ' Get Current Layer
  19.         CurLay = Sys(3) 
  20. Num = 0
  21. Num2 = 0
  22. Num$ = ""
  23. ' Loop for Adding all the Area Attributes up
  24.     for a = 1 to Sys(9)
  25.         getattr a, type, select, laynum, group, red, green, blue
  26.     if laynum = 12 then 
  27.         if type = 15 then
  28.             Entity a
  29.             Temp$ = Sys$(1)
  30.             Num = Sys$(1)
  31.             Num2 = Num2 + Num
  32.             Num$ = Num2
  33.             ' Message Num$
  34.             Area1 = Num2
  35.         endif
  36.     endif
  37.     next a
  38. Num = 0
  39. Num2 = 0
  40. Num$ = ""
  41. ' Loop for Adding all the Length Attributes up
  42.     for a = 1 to Sys(9)
  43.         getattr a, type, select, laynum, group, red, green, blue
  44.     if laynum = 13 then 
  45.         if type = 15 then
  46.             Entity a
  47.             Temp$ = Sys$(1)
  48.             Num = Sys$(1)
  49.             Num2 = Num2 + Num
  50.             Num$ = Num2
  51.             ' Message Num$
  52.             Len1 = Num2
  53.         endif
  54.     endif
  55.     next a
  56. 'Print Area1
  57. 'AnyKey
  58. 'Print Len1
  59. 'AnyKey
  60.             ' Create the Area Info Box    
  61.             ' Convert to Strings for use in Text Block
  62.                 Precision 0
  63.                 Area2$ = Area1
  64.                 Len2$ = Len1
  65.             ' Strings for Text Labels
  66.                 Area$ = "Sm"
  67.                 Len$ = "Lm"
  68.                 Precision 2
  69.             ' Select Object when Created is on
  70.                 Sys(242) = 1
  71.             '
  72.             ' Get Current Drawing Color    
  73.                 ccRed = Sys(300)
  74.                 ccGreen = Sys(301)
  75.                 ccBlue = Sys(302)
  76.             ' Silent Mode Off
  77.                 Sys(36) = 1
  78.             ' Create New File to draw Area box in
  79.                 >New
  80.                 {
  81.                 }
  82.             ' Back to Layer 11
  83.                 Layer(11) = 14
  84.                 '
  85.             ' Not sure if this is still needed . . . 
  86.                 MinnY = Sys(187)
  87.             ' Make Text Block of information
  88.                 >TextBlock
  89.                 {
  90.                 <size [TH]
  91.                 <Distance 0.5
  92.                 <TextBegin
  93.                 <Text [Area$]
  94.                 <Text  [Len$]
  95.                 <justification 2
  96.                 <pointxyz 0, [MinnY - 20], 0
  97.                 }
  98.             ' Get Current Max X values to place labled behind the text values
  99.                 M = Sys(198)
  100.                 M = M + 1
  101.     '        ' Reset Color
  102.     '            Sys(300) = ccRed
  103.     '            Sys(301) = ccGreen
  104.     '            Sys(302) = ccBlue
  105.         ' Set Color to Red
  106.                 Sys(300) = 255
  107.                 Sys(301) = 0
  108.                 Sys(302) = 0
  109.                     '
  110.             ' Select Object when Created is off
  111.                 Sys(242) = 0
  112.             ' Make Text Block of information
  113.                 >TextBlock
  114.                 {
  115.                 <Style 0
  116.                 <Distance 0.5
  117.                 <TextBegin
  118.                 <Text [Area2$]
  119.                 <Text [Len2$]
  120.                 <justification 0
  121.                 <pointxyz [M], [MinnY - 20], 0
  122.                 }
  123.             '
  124.             ' Select Object when Created is off
  125.                 Sys(242) = 0
  126.             '
  127.             ' Select Entire Drawing
  128.                 >SelectAll
  129.                 {
  130.                 }
  131. ' Get Min and Max drawing information
  132.         MinX = Sys(196) - 1
  133.         MinY = Sys(197) - 1
  134.         MaxX = Sys(198) + 1
  135.         MaxY = Sys(199) + 1
  136.     '
  137.     ' Select Object when Created is off
  138.         Sys(242) = 0
  139.     '
  140.     '        ' Reset Color
  141.                 Sys(300) = ccRed
  142.                 Sys(301) = ccGreen
  143.                 Sys(302) = ccBlue
  144.  
  145. ' Set Current Line Width to Zero
  146.     Sys(6) = 0
  147.     '
  148.     ' Draw Bounding Box
  149.         >Box
  150.         {
  151.         <pointxyz [MinX,MinY],0
  152.         <pointxyz [MaxX,MaxY],0
  153.         }
  154.     '    
  155.             ' Select Entire Drawing
  156.                 >SelectAll
  157.                 {
  158.                 }
  159.  
  160.             ' Scale down the Info Box to a much smaller size
  161.                 ' Based on Diff in line 5
  162.                 ' Move Info Box to resize it 
  163.             '        >Move
  164.             '        {
  165.             '        <Type 0
  166.             '        <Pointxyz 0, 0, 0
  167.             '        <Pointrel [Diff], 0, 0
  168.             '        }
  169.             '        '
  170.             ' Copy Area Box back into main drawing
  171.                 >Copy
  172.                 {
  173.                 }
  174.             '
  175.             ' Close Temp Drawing
  176.                 >Close
  177.                 {
  178.                 <SaveChanges 0
  179.                 }
  180.             ' Silent Mode Off
  181.                 Sys(36) = 0
  182.             ' Refresh the Screen
  183.                 >Regenerate
  184.                 {
  185.                 }
  186.             ' Back to Layer 11
  187.                 Layer(11) = 14
  188.                 '
  189.             ' Paste the info box in again
  190.                 >Paste
  191.                 {
  192.                 <Type 0
  193.                 ' 0 = Changeable scale (based on distance between handles 1 and 2); 1 = Fixed scale (always paste at original size)
  194.                 <SelectOnly 0
  195.                 ' 
  196.                 ' 0 = select the pasted object; 1 = leave the pasted object unselected
  197.                 <pointxyz 0,0,0
  198.                 }
  199.                 '
  200.             ' Select Layer 11
  201.                 >SelectLayer
  202.                 {    
  203.                 <Layer 11
  204.                 }
  205.             ' Get Min and Max of the current Selection
  206.                 MinX = Sys(196) 
  207.                 MinY = Sys(197) 
  208.                 MaxX = Sys(198) 
  209.                 MaxY = Sys(199) 
  210.             ' Set Handle
  211.                 >SetHandle
  212.                 {
  213.                 <pointxyz [MinX,MinY],0
  214.                 <pointxyz [MaxX,MinY],0
  215.                 }
  216.             ' Loop for Moving Box from Layer 11 to the current layer
  217.                 for a = 1 to Sys(9)
  218.                     getattr a, type, select, laynum, group, red, green, blue
  219.                     
  220.                     if laynum = 11 then laynum = 14
  221.                         Putattr a, type, select, laynum, group, red, green, blue
  222.                     next a
  223.             ' Switch to and Name Layer 9
  224.                 Sys(3) = 14
  225.                 Sys$(93) = "6x6 Master Info Boxes"
  226.                 '    
  227.             ' Silent Mode Off
  228.                 Sys(36) = 0
  229.                 '
  230.             ' Refresh the Drawing
  231.                 >Regenerate
  232.                 {
  233.                 }
  234.             ' Move the Box
  235.                 >Move
  236.                 {
  237.                 <Type 0
  238.                 }
  239.                 '
  240.             ' Refresh the Screen to see text in area box
  241.                 >Regenerate
  242.                 {
  243.                 }
  244.                 '
  245.             ' Deselect the Box after it's been placed
  246.                 >PointSelect
  247.                 {
  248.                 <Type 0
  249.                 <pointxyz -100, -100, 100
  250.                 }
  251.                 '
  252.             ' Return to previous Current Layer
  253.                 Sys(3) = CurLay
  254.                 '
  255. ' Section to draw Master Material Box on Layer 14
  256. ' Routine to Calculate values for Large Info Boxes
  257.   Calc1:
  258.       ' Calculate and display MTee
  259.         Precision 2    
  260.         MTeeN = Area1 * 0.286
  261.         MTeeC = MTeeN / 25
  262.         MTeeN2 = ROUND(MTeeN)
  263.         ' MTeeC2 = ROUND(MTeeC)
  264.         MTemp = MTeeC + .5
  265.         MTeeC2 = ROUND(MTemp)
  266.         '
  267.     ' Calculate and display 1.2CN
  268.         CN12 = Area1 * 1.65
  269.         CNC12 = CN12 / 75
  270.         ' CN122 = CN12
  271.         CN122 = ROUND(CN12)
  272.         '  CNC122 = CNC12
  273.         CTemp = CNC12 + .5
  274.         CNC122 = ROUND(CTemp)
  275.         '
  276.     ' Calculate and display 1.6CN
  277.         CN6 = Area1 * 1.61
  278.         CN6C = CN6 / 75
  279.           CN62 = ROUND(CN6)
  280.         ' CN62 = ROUND(CN6)
  281.          ' CN6C2 = CN6C
  282.         C6Temp = CN6C + .5
  283.         CN6C2 = ROUND(C6Temp)
  284.         '
  285.     ' Calculate and display ST Fix
  286.         STFix = Area1 * 0.765
  287.         STFixC = STFix / 100
  288.         STFixD = STFixC + .5
  289.         'STFixC = ROUND(STFixD)
  290.                 STFixC2 = STFixC
  291.         STFix2 = ROUND(STFix)
  292.     ' Calculate and display Rods T
  293.         RodsT = Area1 * 0.765
  294.         RodsTC = RodsT / 100
  295.         RodsTD = RodsTC + .5
  296.         'RodsTC = ROUND(RodsTD)
  297.         RodsTC2 = RodsTC
  298.         RodsT2 = RodsT
  299.     ' Calculate and display Rods B
  300.         RodsB = Area1 * 0.765
  301.         RodsBC = RodsB / 100
  302.         RodsBD = RodsBC + .5
  303.         'RodsBC = ROUND(RodsBD)
  304.         ' RodsBC2 = RodsBC
  305.         RodsB2 = RodsB
  306.     ' Calculate and display Channel
  307.     ' Apply Channel Adjustment from Earlier
  308.         Chan = Chan + AddLen
  309.         Chan = Len1 / 3
  310.         'Chan2 = ROUND(Chan)
  311.         Chan2C = Chan / 24
  312.         'ChTemp = Chan2C + .5
  313.         'Chan2C = ROUND(ChTemp)
  314.     ' Resolve Panel Choice for the user
  315.         Panel = .36
  316.     ' Calculate and display Panels
  317.         Ar = Area1 * 0.065
  318.         Pan1 = Area1 + Ar
  319.         Pan2 = Pan1 / Panel
  320.         Pan3 = Pan2
  321.         Precision 2
  322.     ' Apply Panel Reduction
  323.         Pan3 = Pan3 - PanNum2    
  324.         Precision 2
  325.         PTemp = Pan3 + .05
  326. '        Pan3 = ROUND(PTemp)
  327.         '
  328. ' Routine to make smaller info box if area is less than or equal to 46 sm
  329.   Small:
  330. ' Create New File
  331.     >New
  332.     {
  333.     }
  334.     ' Silent Mode On
  335.         Sys(36) = 1
  336.     '
  337.     ' Make Layer 11 the current layer
  338.         Layer(11) = 14
  339.     '
  340.     ' Create String Variables for Text Block
  341.     ' Variables in the No. Column need to be integers only
  342.         Precision 0
  343.         MTeeN2$ = MTeeN2
  344.         CNC122$ = CN122
  345.         CN62$ = CN62
  346.         STFix2$ = STFixC
  347.         RodsT2$ = RodsTC
  348.         RodsB2$ = RodsBC
  349.         Chan2$ = Chan
  350.     ' Variables in the CTS column need one place precision
  351.         Precision 1
  352.         MTeeC2$ = MTeeC
  353.         CN122$ = CNC12
  354.         CN6C2$ = CN6C
  355.         STFixC2$ = STFixC
  356.         RodsTC2$ = RodsTC
  357.         RodsB2$ = RodsBC
  358.         Chan2C$ = Chan2C
  359.         Pan3$ = Pan3
  360.     ' Prompt user for text height
  361.     '    Sys$(41) = "Text Height . . ."
  362.     '    Input "Enter the Text Height for the Info Box . . . (Enter = 1)", TH
  363.     ' Check for Exit Condition on Input box
  364.     '    if Sys(999) = 1 then 
  365.     '        Message "Program Stopped by User."
  366.     '        End
  367.     '    endif
  368. ' Check for valid entries
  369.     'if TH = 0 then TH = 1
  370. ' Rem this back in if text sizes under 1 become a problem
  371.     ' if TH < 1 then TH = 1
  372. ' Half Text height
  373.     HTH = TH / 2
  374. ' Set Spacing for all text blocks at 1, DO NOT CHANGE THIS !!
  375.     SP = 1
  376. ' Get Old Text Height
  377.     OLDTH = Sys(12)
  378. ' Set new Text height
  379.     Sys(12) = TH
  380.     Six = 1
  381.     if Six = 1 then
  382.     ' Text Block with 0.6
  383.         >TextBlock
  384.         {
  385.         <Style 0
  386.         <Distance [SP]
  387.         <TextBegin
  388.         <Text "   "
  389.         <Text " T  "
  390.         <Text "1.2 "
  391.         <Text "0.6 "
  392.         <Text "Fix "
  393.         <Text "T R "
  394.         <Text "B R "
  395.         <Text "Ch "
  396.         <justification 1    
  397.         <pointxyz 0, 0, 0    
  398.         }
  399.     else
  400.     ' Text Block without 0.6
  401.         >TextBlock
  402.         {
  403.         <Distance [SP]
  404.         <TextBegin
  405.         <Text "   "
  406.         <Text " T  "
  407.         <Text "1.2 "
  408.         <Text "    "
  409.         <Text "Fix "
  410.         <Text "T R "
  411.         <Text "B R "
  412.         <Text "Ch "
  413.         <justification 1
  414.         <pointxyz 0, 0, 0
  415.         }
  416.     end if
  417.     ' Set Color to Red
  418.         Sys(300) = 255
  419.         Sys(301) = 0
  420.         Sys(302) = 0
  421.     '
  422. ' Draw Number Column Values
  423.     if Six = 1 then
  424.     ' Text Block with 0.6
  425.         >TextBlock
  426.         {
  427.         <Distance [SP]
  428.         <TextBegin
  429.         <Text "   "
  430.         <Text [MTeeC2$]
  431.         <Text [CN122$]
  432.         <Text [CN6C2$]
  433.         <Text [STFixC2$]
  434.         <Text [RodsTC2$]
  435.         <Text [RodsB2$]
  436.         <Text [Chan2C$]
  437.     '    <Text [MTeeN2$]
  438.     '    <Text [CNC122$]
  439.     '    <Text [CN62$]
  440.     '    <Text [STFix2$]
  441.     '    <Text [RodsT2$]
  442.     '    <Text [RodsB2$]
  443.     '    <Text [Chan2$]
  444.         <justification 1
  445.         <pointxyz [HTH * 8], 0, 0
  446.         }
  447.     else
  448.     ' Text block without 0.6
  449.         >TextBlock
  450.         {
  451.         <Distance [SP]
  452.         <TextBegin
  453.         <Text "   "
  454.         <Text [MTeeN2$]
  455.         <Text [CNC122$]
  456.         <Text "   "
  457.         <Text [STFix2$]
  458.         <Text [RodsT2$]
  459.         <Text [RodsB2$]
  460.         <Text [Chan2$]
  461.         <justification 1
  462.         <pointxyz [HTH * 8], 0, 0
  463.         }
  464.     end if
  465.     ' Set Color back to normal
  466.         Sys(300) = ccRed
  467.         Sys(301) = ccGreen
  468.         Sys(302) = ccBlue
  469.     '
  470.     ' Text Title Block for Ref
  471.         >TextBlock
  472.         {
  473.         <Distance [SP]
  474.         <Style 0
  475.         <TextBegin
  476.         <Text "Total cts"
  477.         <justification 1    
  478.         <pointxyz [HTH*3.5], 0, 0    
  479.         }
  480.     ' Text Block for No
  481.     '    >TextBlock
  482.     '    {
  483.     '    <Distance [SP]
  484.     '    <TextBegin
  485.     '    <Style 0
  486.     '    <Text "Total cts"
  487.     '    <justification 1
  488.     '    <pointxyz [HTH * 8], 0, 0
  489.     '    }
  490. '
  491. ' Set Current Line Thickness to Zero
  492.     Sys(6) = 0
  493.     '
  494. ' Draw Title Block Box
  495.     >Box
  496.     {
  497.     <Pointxyz [-TH*2], [TH/2], 0
  498.     <Pointrel [TH*8], [-TH*2], 0
  499.     }
  500. '
  501. ' Draw First 3 value Box
  502.     >Box
  503.     {
  504.     <Pointxyz [-TH*2], [-TH*1.5], 0
  505.     <Pointrel [TH*8], [-TH*6], 0
  506.     }
  507. '
  508. ' Update Current Y Value 
  509.     CurY = TH*1.5
  510.     CurY = CurY + TH*6
  511. '
  512. ' Draw second 3 value Box
  513.     >Box
  514.     {
  515.     <Pointxyz [-TH*2], [-CurY], 0
  516.     <Pointrel [TH*8], [-TH*6], 0
  517.     }
  518.     '
  519. ' Update Current Y Value
  520.     CurY = CurY + TH*6
  521. '
  522. ' Draw Channel Box
  523.     >Box
  524.     {
  525.     <Pointxyz [-TH*2], [-CurY], 0
  526.     <Pointrel [TH*8], [-TH*2], 0
  527.     }
  528. '
  529. ' Update Current Y Value
  530.     CurY = CurY + TH*2
  531. '
  532. ' Draw Left Column Line
  533.     >Line
  534.     {
  535.     <Pointxyz [TH*2], [TH-TH*2.5], 0
  536.     <Pointxyz [TH*2], [-CurY], 0
  537.     }
  538. '
  539. ' Draw Right Column Line
  540.     >Line
  541.     {
  542.     <Pointxyz [TH*6], [TH/2], 0
  543.     <Pointxyz [TH*6], [-CurY], 0
  544.     }
  545. ' Divide by however many the user says are in a carton
  546.     PanNum = 10
  547.     NewNum = Pan3 / PanNum
  548. ' Round the Result up since we need the next full carton
  549. '    Precision 1
  550. '    NewNum$ = NewNum
  551. '    a$ = RIGHT$(NewNum, 1)
  552. '    if a$ = "0" then goto Done3
  553. '    Precision 0
  554. '    NewNum2 = NewNum
  555. '    NewNum = NewNum2 + 1
  556. Done3:
  557.     Precision 1
  558.     NewNum3 = NewNum
  559.     NewNum2$ = NewNum3,"cts"
  560.     Precision 2
  561. ' Select Object when Created is on
  562.     Sys(242) = 1
  563. '
  564. ' Print Panels at info box bottom
  565.     >Text2D
  566.     {
  567.     <justification 1
  568.     <size [TH]
  569.     <text "Panels"
  570.     <angle 0
  571.     <Pointxyz 0, [-CurY-TH*2], 0
  572.     }
  573. ' Select Object when Created is off
  574.     Sys(242) = 0
  575. ' Get Current Max X values to place labled behind the text values
  576.     M = Sys(198)
  577.     M = M + 1
  578.     N = TH * 4 + M
  579. ' Set Color to Red
  580.     Sys(300) = 255
  581.     Sys(301) = 0
  582.     Sys(302) = 0
  583. ' Add Carton # and cts
  584.     >Text2D
  585.     {
  586.     <justification 0
  587.     <size [TH]
  588.     <text [NewNum2$]
  589.     <angle 0
  590.     <Pointxyz [M], [-CurY-TH*2], 0
  591.     }
  592. ' Reset Color
  593.     Sys(300) = ccRed
  594.     Sys(301) = ccGreen
  595.     Sys(302) = ccBlue
  596.     '
  597. '
  598. ' Select All
  599.         >SelectAll
  600.         {
  601.         }
  602.     ' Copy Area Box back into main drawing
  603.                 >Copy
  604.                 {
  605.                 }
  606.             '
  607.             ' Close Temp Drawing
  608.                 >Close
  609.                 {
  610.                 <SaveChanges 0
  611.                 }
  612.             ' Refresh the Screen
  613.                 >Regenerate
  614.                 {
  615.                 }
  616.             ' Back to Layer 11
  617.                 Layer(11) = 14
  618.                 '
  619.             ' Paste the info box in again
  620.                 >Paste
  621.                 {
  622.                 <Type 0
  623.                 ' 0 = Changeable scale (based on distance between handles 1 and 2); 1 = Fixed scale (always paste at original size)
  624.                 <SelectOnly 0
  625.                 ' 
  626.                 ' 0 = select the pasted object; 1 = leave the pasted object unselected
  627.                 <pointxyz 0,0,0
  628.                 }
  629.                 '
  630.             ' Select Layer 11
  631.                 >SelectLayer
  632.                 {    
  633.                 <Layer 11
  634.                 }
  635.             ' Get Min and Max of the current Selection
  636.                 MinX = Sys(196) 
  637.                 MinY = Sys(197) 
  638.                 MaxX = Sys(198) 
  639.                 MaxY = Sys(199) 
  640.             ' Set Handle
  641.                 >SetHandle
  642.                 {
  643.                 <pointxyz [MinX,MinY],0
  644.                 <pointxyz [MaxX,MinY],0
  645.                 }
  646.     ' Loop for Moving Box from Layer 11 to the LLay layer
  647.         for a = 1 to Sys(9)
  648.             getattr a, type, select, laynum, group, red, green, blue
  649.             if laynum = 11 then laynum = 14
  650.                 Putattr a, type, select, laynum, group, red, green, blue
  651.             next a
  652.     LLay = 14
  653.     if LLay = 14 then
  654.     ' Make Layer 14 Current and name it
  655.         Layer(14) = 14
  656.         Sys$(93) = "6x6 Master Material Boxes"
  657.     endif
  658.     ' Silent Mode Off
  659.         Sys(36) = 0
  660.     '
  661.     ' Refresh the Screen
  662.         >Regenerate
  663.         {
  664.         }
  665.     '
  666.     ' Move the Box
  667.         >Move
  668.         {
  669.         <Type 0
  670.         }
  671.     '
  672.     ' Refresh the Screen
  673.         >Regenerate
  674.         {
  675.         }
  676.     '
  677.     ' Deselect the Box after it's been placed
  678.         >PointSelect
  679.         {
  680.         <Type 0
  681.         <pointxyz -100, -100, 100
  682.         }
  683.     ' Return to previous Current Layer
  684.         Sys(3) = CurLay
  685.     ' 
  686.  
  687.